<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="h-ui-font/iconfont.min.css" />
		<link rel="stylesheet" type="text/css" href="css/jquery-weui.min.css" />
		<link rel="stylesheet" type="text/css" href="css/weui.min.css" />
		<script src="js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/vue(1).js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			body {
				width: 100%;
				margin: 0px auto;
				min-width: 320px;
				max-width: 640px;
			}
			
			.top {
				width: 100%;
				height: 50px;
				min-width: 320px;
				max-width: 640px;
				line-height: 50px;
				color: white;
				font-size: 18px;
				text-indent: 10px;
				position: fixed;
				z-index: 1000;
				background-color: #0F88EB;
			}
			
			.top a {
				color: white;
				margin-right: 10px;
			}
			
			.contents {
				width: 100%;
				padding-top: 50px;
				padding-bottom: 40px;
				overflow: auto;
				/*border: 1px solid red;*/
			}
			
			.weui-tabbar {
				min-width: 320px;
				max-width: 640px;
				height: 40px;
				position: fixed;
			}
			
			.message {
				width: 100%;
				height: 100px;
				overflow: hidden;
				color: black;
				position: relative;
			}
			
			.message div {
				float: left;
				position: absolute;
				top: 0px;
				bottom: 0px;
				left: 10px;
				right: 0px;
				margin: auto 0px;
			}
			
			.message div:first-child {
				width: 40px;
				height: 40px;
				top: -20px;
				border-radius: 20px;
				overflow: hidden;
			}
			
			.message div:first-child img {
				width: 100%;
			}
			
			.message div:last-child {
				height: 80px;
				left: 70px;
				line-height: 30px;
				color: black;
				font-size: 14px;
			}
			
			.message div:last-child p:nth-of-type(1),
			.message div:last-child p:nth-of-type(2) {
				cursor: pointer;
				height: 30px;
			}
			
			.message div:last-child p:nth-of-type(2) {
				text-overflow: ellipsis;
				overflow: hidden;
				white-space: nowrap;
			}
			
			.message div:last-child p:last-child {
				font-size: 12px;
				color: #a0a0a0;
				border-bottom: 1px solid #c0c0c0;
			}
			
			.message div:last-child p:last-child i {
				font-size: 18px;
				float: right;
				cursor: pointer;
				margin-right: 15px;
			}
			
			.weui-cell {
				width: 100%;
				color: #808080;
			}
			
			.weui-cell__bd {
				width: 80%;
				border-bottom: 1px solid #c0c0c0;
			}
			
			.weui-cell__hd {
				width: 50px;
				font-size: 25px;
				margin-left: 20px;
			}
		</style>
	</head>

	<body>
		<div class="top">
			<a href="content.html" class="Hui-iconfont Hui-iconfont-slider-left"></a>评论</div>
		<div class="contents">
			<div class="message" v-for="item in json1[2]">
				<div><img :src="item.p_time" /></div>
				<div>
					<p v-html="item.p_id">name</p>
					<p v-html="item.p_text">评论内容</p>
					<p><span v-html="item.p_zan">00:00</span><i class="Hui-iconfont Hui-iconfont-zan2"></i></p>

				</div>
			</div>

		</div>
		<div class="weui-tabbar">
			<div class="weui-cell">
				<div class="weui-cell__bd">
					<input class="weui-input" type="text" placeholder="添加评论" v-model="pinglun">
				</div>
				<div class="weui-cell__hd"><label class="weui-label Hui-iconfont Hui-iconfont-fabu" v-on:click="fabiao()"></label></div>
			</div>
		</div>
		<script type="text/javascript">
			var ss;
			var dd;
			var userid;
			var tieid = sessionStorage.getItem("contentid");
			var year = new Date();
			var nian = year.getFullYear();
			var yue = (year.getMonth() + 1) < 10 ? "0" + (year.getMonth() + 1) : year.getMonth() + 1;
			var day = year.getDate() < 10 ? "0" + year.getDate() : year.getDate();
			var str1 = nian + "-" + yue + "-" + day;
			var vue = new Vue({
				el: "body",
				data: {
					json1: [],
					pinglun: "",
					iszan: false,

				},
				methods: {
					auth: function() {
						$.ajax({
							type: 'get',
							//async:false,
							url: "http://v2.mashupcloud.cn/developer/auth.do",
							data: {
								appkey: 'FvWrIYOQoTUYVbscUNQoQAVqsLnZqKEN',
								appsecret: 'ugCfcSmyLkcbCGfIuFOPEgTgPQPbyJSE'

							},
							success: function(json) {
								//		            console.log(json);
								ss = JSON.parse(json)[1];
								dd = JSON.parse(json)[2];
								vue.content();
							},
							error: function(json) {

								console.log("err:" + json);

							}
						});
					},
					content: function() {
						$.ajax({
							type: 'get',
							url: "http://v2.mashupcloud.cn/SQL/sele_ping/",
							data: {
								appid: dd,
								token: ss,
								name: 'sele_ping',
								_v1: tieid
							},
							success: function(json) {
								vue.json1 = JSON.parse(json);
								console.log(vue.json1[2])
								for(var i = 0; i < vue.json1[2].length; i++) {
									$.ajax({
										type: "get",
										url: "http://v2.mashupcloud.cn/SQL/sele_user/",
										async: false,
										data: {
											appid: dd,
											token: ss,
											name: 'sele_user',
											_v1: vue.json1[2][i].p_id
										},
										success: function(json) {
											console.log(JSON.parse(json)[2][0].nicheng);
											vue.json1[2][i].p_id = JSON.parse(json)[2][0].nicheng;
											vue.json1[2][i].p_zan = JSON.parse(json)[2][0].touxiang;
										}
									});
								}
							},
							error: function(json) {
								console.log("err:" + json);

							}
						});

					},
					fabiao: function() {
						console.log(111)
						var userid = sessionStorage.getItem("userid");
						console.log(vue.pinglun)
						$.ajax({
							type: 'get',
							url: "http://v2.mashupcloud.cn/SQL/into_p/",
							data: {
								appid: dd,
								token: ss,
								name: 'into_p',
								_v1: tieid,
								_v2: vue.pinglun,
								_v3: userid,
								_v4: str1
							},
							success: function(json) {
								console.log(JSON.parse(json));
								console.log("评论成功");
								$(".weui-input").val("");
								location.reload();
							},
							error: function(json) {
								console.log("err:" + json);
							}
						});

					},
				}
			});
			vue.auth();
		</script>
	</body>

</html>